// pages/logistics_detail/index.js
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        goods:{
            id:'0',
            img: '/img/news.png',
            name:'零食坚果炒货特产干果巴达木',
        },
        express:{
            name:'中通快递',
            img:'/img/zhongtong.png',
            number:'123456789',
            phone:'15665597078',
            address:'合肥市蜀山区西湖国际广场D座910皮诺客科技有限公司'
        },
        list:[
            {
                time:'2018-12-28 09:46',
                text1:'已出库',
                text2:'您的包裹已出库',
            },
            {
                time: '2018-12-28 09:46',
                text1: '已发货',
                text2: '卖家已发货',
            },
            {
                time: '2018-12-28 09:46',
                text1: '已下单',
                text2: '您的订单待配货',
            },
            {
                time: '2018-12-28 09:46',
                text1: '您的订单开始处理',
                text2: '',
            },
            {
                time: '2018-12-28 09:46',
                text1: '您的订单开始处理',
                text2: '',
            },
            {
                time: '2018-12-28 09:46',
                text1: '您的订单开始处理',
                text2: '',
            },
            {
                time: '2018-12-28 09:46',
                text1: '您的订单开始处理',
                text2: '',
            },
        ],
    },
call:function(){
    var that=this;
    // wx.makePhoneCall({
    //     phoneNumber: that.data.express.phone,
    // })
},
copy:function(){
    var that=this;
    wx.setClipboardData({
        data: that.data.express.number,
        success:function(res){
            wx.getClipboardData({
                success:function(res){
                    wx.showToast({
                        title: '复制成功',
                    })
                },
            })
        },
    })
},
    /**
     * 生命周期函数--监听页面加载
     */
  onLoad: function (options) {
    var that = this;
    var id = options.id;
    that.setData({
      id: id
    })
  },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
  onShow: function () {
    var that = this;

    wx.request({
      url: app.siteInfo.shoppath + 'expdetail',
      method: "get",
      data: {
        orderid: that.data.id,
        uid: app.siteInfo.uid,
        pid: app.siteInfo.pid,
        com_part_id: app.siteInfo.com_part_id,
      },
      success: function (res) {
        console.log(res)
        that.setData({
          expinfo: res.data.expinfo,
          expdata: res.data.expdata
        })
        // if (res.data.expressnews.status != 200) {
        //   wx.showToast({
        //     title: '暂无物流信息',
        //     image: '/img/fail.png',
        //     duration: 1500
        //   })
        //   setTimeout(function () {
        //     wx.navigateTo({
        //       url: '/pages/order_list/order_list',
        //     })
        //   }, 1500);
        // } else {
        //   that.setData({
        //     expinfo:res.data.expinfo,
        //     expdata:res.data.expdata
        //   })
        // }
      }
    })
  },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
  onShareAppMessage: function () {
    wx.request({
      url: app.siteInfo.siteroot + 'relay',
      method: "post",
      data: {
        uid: app.siteInfo.uid,
        pid: app.siteInfo.pid,
        replaysource: "index"
      },
      success: function (res) { }
    })
    return {
      title: app.siteInfo.sharetitle,
      path: "/pages/index/index?share_card_id=" + app.siteInfo.pid + "&shareid=" + app.siteInfo.uid,
      success: function (a) {
        wx.request({
          url: app.siteInfo.siteroot + 'relay',
          method: "post",
          data: {
            uid: app.siteInfo.uid,
            pid: app.siteInfo.pid
          },
          success: function (res) { }
        })
      },
      fail: function (a) { }
    };
  }
})